home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kdeprint / kmmanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.8 KB  |  184 lines

  1. /*
  2.  *  This file is part of the KDE libraries
  3.  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License version 2 as published by the Free Software Foundation.
  8.  *
  9.  *  This library is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  *  Library General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU Library General Public License
  15.  *  along with this library; see the file COPYING.LIB.  If not, write to
  16.  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  *  Boston, MA 02110-1301, USA.
  18.  **/
  19.  
  20. #ifndef KMMANAGER_H
  21. #define KMMANAGER_H
  22.  
  23. #if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ )
  24. #warning internal header, do not use except if you are a KDEPrint developer
  25. #endif
  26.  
  27. #include <kdeprint/kmprinter.h>
  28.  
  29. #include <qobject.h>
  30. #include <qstring.h>
  31. #include <qptrlist.h>
  32.  
  33. class DrMain;
  34. class KMDBEntry;
  35. class KMVirtualManager;
  36. class KMSpecialManager;
  37. class QWidget;
  38. class KActionCollection;
  39. class PrinterFilter;
  40.  
  41. /**
  42.  * @internal
  43.  * This class is internal to KDEPrint and is not intended to be
  44.  * used outside it. Please do not make use of this header, except
  45.  * if you're a KDEPrint developer. The API might change in the
  46.  * future and binary compatibility might be broken.
  47.  */
  48. class KDEPRINT_EXPORT KMManager : public QObject
  49. {
  50.     Q_OBJECT
  51.  
  52. friend class KMVirtualManager;
  53. friend class KMSpecialManager;
  54. friend class KMFactory;
  55.  
  56. public:
  57.     enum PrinterOperations {
  58.         PrinterEnabling  = 0x01,
  59.         PrinterCreation  = 0x02,
  60.         PrinterDefault   = 0x04,
  61.         PrinterTesting   = 0x08,
  62.         PrinterConfigure = 0x10,
  63.         PrinterRemoval   = 0x20,
  64.         PrinterAll       = 0xFF
  65.     };
  66.     enum ServerOperations {
  67.         ServerRestarting = 0x1,
  68.         ServerConfigure  = 0x2,
  69.         ServerAll        = 0xF
  70.     };
  71.  
  72.     KMManager(QObject *parent = 0, const char *name = 0);
  73.     virtual ~KMManager();
  74.  
  75.     static KMManager* self();
  76.  
  77.     // error management functions
  78.     QString errorMsg() const        { return m_errormsg; }
  79.     void setErrorMsg(const QString& s)    { m_errormsg = s; }
  80.  
  81.     // support management ?
  82.     bool hasManagement() const         { return m_hasmanagement; }
  83.  
  84.     // printer management functions
  85.     virtual bool createPrinter(KMPrinter *p);
  86.     virtual bool removePrinter(KMPrinter *p);
  87.     virtual bool enablePrinter(KMPrinter *p, bool on);
  88.     virtual bool startPrinter(KMPrinter *p, bool on);
  89.     virtual bool completePrinter(KMPrinter *p);
  90.     virtual bool completePrinterShort(KMPrinter *p);
  91.     virtual bool setDefaultPrinter(KMPrinter *p);
  92.     virtual bool testPrinter(KMPrinter *p);
  93.     bool upPrinter(KMPrinter *p, bool state);
  94.     bool modifyPrinter(KMPrinter *oldp, KMPrinter *newp);
  95.     bool removePrinter(const QString& name);
  96.     bool enablePrinter(const QString& name, bool state);
  97.     bool startPrinter(const QString& name, bool state);
  98.     bool completePrinter(const QString& name);
  99.     bool setDefaultPrinter(const QString& name);
  100.     int printerOperationMask() const     { return m_printeroperationmask; }
  101.     int addPrinterWizard(QWidget *parent = 0);
  102.  
  103.     // special printer management functions
  104.     bool createSpecialPrinter(KMPrinter *p);
  105.     bool removeSpecialPrinter(KMPrinter *p);
  106.  
  107.     // printer listing functions
  108.     KMPrinter* findPrinter(const QString& name);
  109.     QPtrList<KMPrinter>* printerList(bool reload = true);
  110.     QPtrList<KMPrinter>* printerListComplete(bool reload = true);
  111.     KMPrinter* defaultPrinter();
  112.     void enableFilter(bool on);
  113.     bool isFilterEnabled() const;
  114.  
  115.     // driver DB functions
  116.     virtual QString driverDbCreationProgram();
  117.     virtual QString driverDirectory();
  118.  
  119.     // driver functions
  120.     virtual DrMain* loadPrinterDriver(KMPrinter *p, bool config = false);
  121.     virtual DrMain* loadDbDriver(KMDBEntry *entry);
  122.     virtual DrMain* loadFileDriver(const QString& filename);
  123.     DrMain* loadDriver(KMPrinter *p, bool config = false);
  124.     virtual bool savePrinterDriver(KMPrinter *p, DrMain *d);
  125.     virtual bool validateDbDriver(KMDBEntry *entry);
  126.  
  127.     // configuration functions
  128.     bool invokeOptionsDialog(QWidget *parent = 0);
  129.     virtual QString stateInformation();
  130.  
  131.     // server functions
  132.     int serverOperationMask() const     { return m_serveroperationmask; }
  133.     virtual bool restartServer();
  134.     virtual bool configureServer(QWidget *parent = 0);
  135.     virtual QStringList detectLocalPrinters();
  136.  
  137.     // additional actions (for print manager)
  138.     virtual void createPluginActions(KActionCollection*);
  139.     virtual void validatePluginActions(KActionCollection*, KMPrinter*);
  140.  
  141.     // utility function
  142.     void checkUpdatePossible();
  143.  
  144. signals:
  145.     void updatePossible( bool );
  146.  
  147. protected:
  148.     // the real printer listing job is done here
  149.     virtual void listPrinters();
  150.  
  151.     // utility functions
  152.     void addPrinter(KMPrinter *p);    // in any case, the pointer given MUST not be used after
  153.                     // calling this function. Useful when listing printers.
  154.     void setHardDefault(KMPrinter*);
  155.     void setSoftDefault(KMPrinter*);
  156.     KMPrinter* softDefault() const;
  157.     KMPrinter* hardDefault() const;
  158.     // this function uncompress the given file (or does nothing
  159.     // if the file is not compressed). Returns wether the file was
  160.     // compressed or not.
  161.     bool uncompressFile(const QString& srcname, QString& destname);
  162.     bool notImplemented();
  163.     void setHasManagement(bool on)        { m_hasmanagement = on; }
  164.     void setPrinterOperationMask(int m)    { m_printeroperationmask = m; }
  165.     void setServerOperationMask(int m)    { m_serveroperationmask = m; }
  166.     QString testPage();
  167.     void discardAllPrinters(bool);
  168.     void setUpdatePossible( bool );
  169.     virtual void checkUpdatePossibleInternal();
  170.  
  171. protected:
  172.     QString            m_errormsg;
  173.     KMPrinterList        m_printers, m_fprinters;    // filtered printers
  174.     bool             m_hasmanagement;
  175.     int            m_printeroperationmask;
  176.     int             m_serveroperationmask;
  177.     KMSpecialManager    *m_specialmgr;
  178.     KMVirtualManager    *m_virtualmgr;
  179.     PrinterFilter    *m_printerfilter;
  180.     bool m_updatepossible;
  181. };
  182.  
  183. #endif
  184.